package com.jkc.xh.fragments;


import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.fragments.core.BaseFragment;
import com.jkc.xh.manager.UserManager;
import com.jkc.xh.models.MessageModel;
import com.jkc.xh.network.RestCallBack;
import com.jkc.xh.network.models.RestError;
import com.jkc.xh.utils.Tool;
import com.jkc.xh.views.widget.NavBar;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.ViewById;

/**
 * 平仓结算
 */
@EFragment(R.layout.fragment_message_detail)
public class MessageDetailFragment extends BaseFragment {

    @ViewById(R.id.nav_bar)
    NavBar nav_bar;
    @FragmentArg("modelExtra")
    String messageId;

    @ViewById
    TextView messageTitle;
    @ViewById
    TextView messageTime;
    @ViewById
    TextView messageContent;

    @AfterViews
    void initData() {
        nav_bar.setOnMenuClickListener(new NavBar.OnMenuClickListener() {
            @Override
            public void onLeftMenuClick(View view) {
                finishFragment();
            }

        });
        showProgress();
        UserManager.getUserCenterMessageDetail(messageId, new RestCallBack<MessageModel>() {
            @Override
            public void success(MessageModel messageModel) {
                closeProgress();
                messageTitle.setText(messageModel.title);
                messageTime.setText(Tool.formatSecondSimpleFullDate(messageModel.create_time));
                messageContent.setText(Html.fromHtml(messageModel.content));
            }

            @Override
            public void failure(RestError error) {
                closeProgress();
            }
        });
    }


}
